<?php
/**
 * Created by PhpStorm.
 * User: 小蛮哼哼哼
 * Email: 243194993@qq.com
 * Date: 2021/10/22
 * Time: 16:01
 * motto: 现在的努力是为了小时候吹过的牛逼！
 */

namespace app\common\business;


use app\common\validate\Weight as ValObj;
use app\common\model\mysql\Weight as ModelObj;
use think\Exception;
use think\facade\Log;

class Weight extends Base
{
    /**
     * @var ValObj
     */
    protected ValObj $valObj;
    /**
     * @var ModelObj
     */
    protected ModelObj $modelObj;

    /**
     *
     */
    public function __construct()
    {
        $this->valObj = new ValObj();
        $this->modelObj = new ModelObj();
    }

    public function add(array $data = []): bool
    {

        if (empty($data['is_gu'])) {
            if (empty($data['money_z'])) {
                throw new Exception("请输入每公斤增加金额");
            }
        }
        if(!empty($data['is_gu'])){
            $data['is_gu'] = intval($data['is_gu']);
        }
        return parent::add($data); // TODO: Change the autogenerated stub
    }


}